import project from './project';
import group from './group';
import file from './file';

class serialize {
  serializeProject(value: project): string {
    console.log(value);
    let json = {
      name: value.getProjectName(),
      author: value.getAuthor(),
      description: value.getProjectDescription(),
      language: value.getLanguage(),
      LICENSE: value.getLICENSE(),
      createDate: value.getCreateDate(),
      lastVisitDate: value.getLastVisitDate(),
      lastEditDate: value.getLastEditDate(),
      fileGroup: this.serializeGroup(value.getFileGroup()),
    };

    return JSON.stringify(json);
  }

  serializeGroup(value: group): any[] {
    //err
    console.log(value);
    let arr: any = [];
    return arr;
  }
  serializeFile(value: file[]): any[] {
    let arr: any = [];
    if (value.length <= 0) {
      return arr;
    }
    value.forEach((e) => {
      let d = {
        name: e.getFileName(),
        content: e.getFileContent(),
      };
      arr.push(d);
    });
    return arr;
  }
}

let serializeProject = new serialize();
export default serializeProject;
